﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;

namespace ShumaDaf
{
    class XMLFilesEnumerable: IEnumerable
    {
        private List<DirectoryInfo> list_fpath;
        MainWindow w;
        public XMLFilesEnumerable(List<string> paths)
            
        {
            
            list_fpath = new List<DirectoryInfo>();
            foreach (string s in paths) 
                this.list_fpath.Add(new DirectoryInfo(s));
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            List<FileInfo> li = new List<FileInfo>();
            foreach (DirectoryInfo di in list_fpath)
            {
                if (di.Exists)
                {
                    FileInfo[] fc = null;
                    try
                    {
                        fc = di.GetFiles("MyMovies.xml", SearchOption.AllDirectories);
                    }
                    catch (Exception e)
                    {
                        
                    }
                    
                    if (fc != null)
                        li.AddRange(fc.ToList<FileInfo>());
                }
            }
            return li.GetEnumerator();
            //return (IEnumerator) new FileEnum(li.ToArray<FileInfo>());
        }
    }
        
}
